def list = [0,1,2,3,4]

println "list.size:" + list.size()
println "list.class:" + list.class

println "list[0]=" + list[0]
println "list.getAt(0)=" + list.getAt(0)
println "list.get(0)=" + list.get(0)

println "list[-1]=" + list[-1]

println "list1-list3:" + list[new IntRange(1,3)]
println "list1-list3:" + list.getAt(new IntRange(1,3))

list.putAt(0, '000')
assert list == ["000", 1, 2, 3, 4]

list.putAt(new IntRange(1,3), 'abc')	// The size will be 3
assert list == list:["000", "abc", 4]

list << [5,6,7,8,9]
assert list == ["000", "abc", 4, [5, 6, 7, 8, 9]]

list << '==='
assert list == ["000", "abc", 4, [5, 6, 7, 8, 9], "==="]

list = [0,1,2,3,4]
list << 5 << 6
assert list == [0,1,2,3,4,5,6]

assert [0,1] + 2 + [3,4] == [0,1,2,3,4]

// Clear the list
list = []

list.addAll([1,2,3])
assert list == [1,2,3]

list.add('abc')
assert list == [1,2,3,'abc']
list.add(3, 'cba')
assert list == [1,2,3,'cba','abc']

list.each{println it}
list.eachWithIndex{ it, i -> println "$i: $it" }

list = [1,2,3]

assert list.find{ it == 2 } == 2
assert list.findAll{ it > 1 } == [2, 3]

assert list.every{it < 5}
assert list.every{it > 0}

assert list.any{it > 1}

assert list.sum() == 6
assert list.join('-') == '1-2-3'

assert list.max() == 3
assert list.min() == 1

assert Collections.max(list) == 3
assert Collections.min(list) == 1

assert ['a', 'b', 'c'].max() == 'c'
assert ['a', 'b', 'c'].min() == 'a'

assert ['a', 'aa', 'aaa'].max{ it.size() } == 'aaa'
assert ['a', 'aa', 'aaa'].min{ it.size() } == 'a'

// reverse method of List
list = [1,2,3]
list = list.reverse()
assert list == [3,2,1]

// reverse method of Collections
list = [1,2,3]
Collections.reverse(list)
assert list == [3,2,1]

assert 'a' in ['a','b','c']
assert ['a','b','c'].pop() == 'c'

// Sort method 
assert [2,1,3].sort() == [1,2,3]
assert ['b','a','c'].sort() == ['a','b','c']

assert 1..3 == [1,2,3]
assert 1..<3 == [1,2]
assert 'a'..'c' == ['a','b','c']

println 'The End'
